package com.it.service;

import com.it.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class DeptFeignFallbackService implements FallbackFactory<DeptFeignService> {
    @Override
    public DeptFeignService create(Throwable throwable) {
        return new DeptFeignService() {
            @Override
            public boolean addDept(Dept dept) {
                return false;
            }

            @Override
            public Dept queryById(Long id) {
                return new Dept()
                        .setId(id)
                        .setName("当前服务已降级，服务不可用！")
                        .setDb_source("数据为空");
            }

            @Override
            public List<Dept> queryAll() {
                return null;
            }
        };
    }
}
